package com.ruoyi.handing.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.handing.domain.AlgsAnimalHanding;
import com.ruoyi.handing.service.IAlgsAnimalHandingService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 动物处理Controller
 * 
 * @author ruoyi
 * @date 2023-03-17
 */
@RestController
@RequestMapping("/animalHanding")
public class AlgsAnimalHandingController extends BaseController
{
    @Autowired
    private IAlgsAnimalHandingService algsAnimalHandingService;

    /**
     * 查询动物处理列表
     */
//    @RequiresPermissions("animalHanding:animalHanding:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsAnimalHanding algsAnimalHanding)
    {
        startPage();
        List<AlgsAnimalHanding> list = algsAnimalHandingService.selectAlgsAnimalHandingList(algsAnimalHanding);
        return getDataTable(list);
    }

    /**
     * 导出动物处理列表
     */
//    @RequiresPermissions("animalHanding:animalHanding:export")
    @Log(title = "动物处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsAnimalHanding algsAnimalHanding)
    {
        List<AlgsAnimalHanding> list = algsAnimalHandingService.selectAlgsAnimalHandingList(algsAnimalHanding);
        ExcelUtil<AlgsAnimalHanding> util = new ExcelUtil<AlgsAnimalHanding>(AlgsAnimalHanding.class);
        util.exportExcel(response, list, "动物处理数据");
    }

    /**
     * 获取动物处理详细信息
     */
//    @RequiresPermissions("animalHanding:animalHanding:query")
    @GetMapping(value = "/{animalHandingId}")
    public AjaxResult getInfo(@PathVariable("animalHandingId") Long animalHandingId)
    {
        return success(algsAnimalHandingService.selectAlgsAnimalHandingByAnimalHandingId(animalHandingId));
    }

    /**
     * 新增动物处理
     */
//    @RequiresPermissions("animalHanding:animalHanding:add")
    @Log(title = "动物处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsAnimalHanding algsAnimalHanding)
    {
        return toAjax(algsAnimalHandingService.insertAlgsAnimalHanding(algsAnimalHanding));
    }

    /**
     * 修改动物处理
     */
//    @RequiresPermissions("animalHanding:animalHanding:edit")
    @Log(title = "动物处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsAnimalHanding algsAnimalHanding)
    {
        return toAjax(algsAnimalHandingService.updateAlgsAnimalHanding(algsAnimalHanding));
    }

    /**
     * 删除动物处理
     */
//    @RequiresPermissions("animalHanding:animalHanding:remove")
    @Log(title = "动物处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{animalHandingIds}")
    public AjaxResult remove(@PathVariable Long[] animalHandingIds)
    {
        return toAjax(algsAnimalHandingService.deleteAlgsAnimalHandingByAnimalHandingIds(animalHandingIds));
    }


//    @RequiresPermissions("animalHanding:animalHanding:edit")
    @Log(title = "动物处理", businessType = BusinessType.INSERT)
    @PostMapping("/{animalHandingIds}")
    public AjaxResult chuli(@PathVariable Long animalHandingIds)
    {
        return toAjax(algsAnimalHandingService.chuli(animalHandingIds));
    }
}
